package com.vd.wmt.process.impl;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.vd.wmt.model.Status;
import com.vd.wmt.model.WageDetail;
import com.vd.wmt.parse.XlsParse;
import com.vd.wmt.process.LoadProcess;
import com.vd.wmt.resource.XlsResource;
/**
 * @desc 加载xls数据
 * @author tudongyun
 *
 */
public class XlsLoadProcess implements LoadProcess {
	private Log log = LogFactory.getLog(XlsLoadProcess.class);
	private Status status = Status.INIT;
	private String errMsg;

	@Override
	public List<WageDetail> process(String fileName) {
		log.info("start process....");
		try {
			this.status = Status.LOADING;
			XlsResource res = new XlsResource(fileName);
			XlsParse parse = new XlsParse();
			List<WageDetail> list = parse.parse(res.getWorkBook(), null);
			this.status=Status.SUCC;
			log.info("parse end....");
			return list;
		} catch (Exception e) {
			log.error("process Exception", e);
			this.status=Status.FAILD;
			errMsg = e.getMessage();
		}
		return null;
	}

	@Override
	public String getError() {
		return errMsg;
	}

	@Override
	public Status getStatus() {
		return status;
	}

}
